package day2;

import java.io.*;

//通过缓冲流 + 新版try-catch实现文件复制
public class TestCopy3 {
    public static void main(String[] args) {
        try (
             FileInputStream fis = new FileInputStream("d://IO//video//a.mp4");
             FileOutputStream fos = new FileOutputStream("d://IO//video//movie//new3.mp4");
             BufferedInputStream bis = new BufferedInputStream(fis);
             BufferedOutputStream bos = new BufferedOutputStream(fos);
        ){
            long start = System.currentTimeMillis();
            int len = 0;
            byte[] bs = new byte[1024];
            while ((len = bis.read(bs)) != -1){
                bos.write(bs,0,len);
            }
            long end = System.currentTimeMillis();
            System.out.println((end-start)+"ms");
        }catch (IOException e){
            e.printStackTrace();
        }
    }
}
